package robotleMvc.ui
{
	import com.net.AssetData;
	import com.ui.controls.Button;
	import com.ui.data.ButtonData;
	import com.ui.data.ComboBoxData;
	import com.ui.manager.UIManager;
	
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.geom.Rectangle;

	public class UIUtil
	{
		public function UIUtil()
		{
		}
		public static function listCellSelected():AssetData
		{
			var inner:Rectangle = new Rectangle( 3, 3, 40, 150-6 );
			var assetData:AssetData = new AssetData( "duihuakuang_bg" );
			assetData.isScaleBitmap = true;
			assetData.inner = inner;
			return assetData;
		}
		public static  function frameOutShow():AssetData
		{
			var inner:Rectangle=new Rectangle(20, 20, (73-40), 446-40);
			var assetData:AssetData=new AssetData("frame_out_show");
			assetData.isScaleBitmap=true;
			assetData.inner=inner;
			return assetData;
		}
		public static  function shoptabmcUp():AssetData
		{
			var inner:Rectangle=new Rectangle(4, 4, (122-4), 27-4);
			var assetData:AssetData=new AssetData("shoptabmc_up");
			assetData.isScaleBitmap=true;
			assetData.inner=inner;
			return assetData;
		}
		public static function blackKuang():AssetData
		{
			var inner : Rectangle = new Rectangle(10, 10, 124, 103);
			var assetData : AssetData = new AssetData("kuang_bg");
			assetData.isScaleBitmap = true;
			assetData.inner = inner;
			return assetData;
		}
		public static function addPic(_parent : Sprite, _x : int, _y : int, _width : int, _height : int, _assetData : AssetData) : DisplayObject
		{
			var pic : DisplayObject = UIManager.getUI(_assetData);
			pic.x = _x;
			pic.y = _y;
			pic.width = _width;
			pic.height = _height;
			_parent.addChild(pic);
			return pic;
	
		}
		public static function getComboBoxData():ComboBoxData
		{
			var data:ComboBoxData = new ComboBoxData();
			data.buttonData.downAsset = data.buttonData.upAsset =  getScaleBitmapAsset( "braces_up", new Rectangle( 10, 5, 55, 10 ) );
			data.buttonData.overAsset =  getScaleBitmapAsset( "braces_over", new Rectangle( 10, 5, 55, 10 ) );
			
			data.listData.bgAsset = getScaleBitmapAsset("useCue_up",new Rectangle( 10, 10, 50, 55 ) );
			return data;
		}
		public static function getScaleBitmapAsset(name:String, inner:Rectangle):AssetData
		{
			var assetData:AssetData = new AssetData( name );
			assetData.isScaleBitmap = true;
			assetData.inner = inner;
			return assetData;
		}
		
		public static function addButton(_parent : Sprite, _x : int, _y : int, _w : int = -1, _h : int = -1, _text : String = "", _color : uint = 0xffffffff, _textSize : uint = 12, skinType : uint = 0) : Button
		{
			var data : ButtonData = new ButtonData();
			data.x = _x;
			data.y = _y;
			if (_w >= 0) data.width = _w;
			if (_h >= 0) data.height = _h;
			data.labelData.textColor = _color;
			data.labelData.text = _text;
			data.labelData.textFormat.size = _textSize;
			data.downColor = _color;
			data.rollOverColor = _color;
			data.upColor = _color;

			
			switch(skinType)
			{
				case 0:
					data.upAsset = btnUp();
					data.downAsset = btnDown();
					data.overAsset = btnOver();
					data.disabledAsset = btnDown();
					break;
				case 1:
					data.upAsset = episodeUp();
					data.downAsset = episodeOver();
					data.overAsset = episodeOver();
					data.disabledAsset = episodeDown();
					break;
				case 2:
					data.upAsset = yellowBtnUp();
					data.downAsset = yellowBtnDown();
					data.overAsset = yellowBtnOver();
					data.disabledAsset = yellowBtnDown();
					break;
				case 3:
					data.upAsset = newStateTipUp();
					data.downAsset = newStateTipDown();
					data.overAsset = newStateTipOver();
					data.disabledAsset = newStateTipDown();
					break;
				case 4:
					data.upAsset = new AssetData("emptySkin");
					data.downAsset = new AssetData("emptySkin");
					data.overAsset = new AssetData("emptySkin");
					data.disabledAsset = new AssetData("emptySkin");
					data.downColor = 0xFFFFDC00;
					data.rollOverColor = 0xFFFFFF;
					break;
				case 5:
					data.upAsset = new AssetData("leaves_up");
					data.downAsset = new AssetData("leaves_down");
					data.overAsset = new AssetData("leaves_over");
					data.disabledAsset = new AssetData("leaves_down");
					break;
				case 6:
					data.upAsset =  darkGreenBtnUp();
					data.downAsset = darkGreenBtnDown();
					data.overAsset =darkGreenBtnOver();
					data.disabledAsset = darkGreenBtnDown();
					break;
				default:
					data.upAsset = btnUp();
					data.downAsset = btnDown();
					data.overAsset = btnOver();
					data.disabledAsset = btnDown();
					break;
				
		

			}
			
			
		
			
			var btn:Button = new Button( data );
			if (_parent)
			{
				_parent.addChild(btn);
			}
			return btn;
		}
		public static function btnUp() : AssetData
		{
			var inner : Rectangle = new Rectangle(4, 3, 66, 17);
			var assetData : AssetData = new AssetData("BtnUp");
			assetData.isScaleBitmap = true;
			assetData.inner = inner;
			return assetData;
		}
		
		public static function btnOver():AssetData
		{
			var inner : Rectangle = new Rectangle(4, 3, 66, 17);
			var assetData : AssetData = new AssetData("BtnOver");
			assetData.isScaleBitmap = true;
			assetData.inner = inner;
			return assetData;
		}
		
		public static function btnDown():AssetData
		{
			var inner : Rectangle = new Rectangle(4, 3, 66, 17);
			var assetData : AssetData = new AssetData("BtnDown");
			assetData.isScaleBitmap = true;
			assetData.inner = inner;
			return assetData;
		}
		
		public static function episodeUp() : AssetData
		{
			var inner : Rectangle = new Rectangle(4, 4, 101, 14);
			var assetData : AssetData = new AssetData("episodeUp");
			assetData.isScaleBitmap = true;
			assetData.inner = inner;
			return assetData;
		}
		
		public static function episodeOver() : AssetData
		{
			var inner : Rectangle = new Rectangle(4, 4, 101, 14);
			var assetData : AssetData = new AssetData("episodeOver");
			assetData.isScaleBitmap = true;
			assetData.inner = inner;
			return assetData;
		}
		
		public static function episodeDown():AssetData
		{
			var inner : Rectangle = new Rectangle(4, 4, 101, 14);
			var assetData : AssetData = new AssetData("episodeDown");
			assetData.isScaleBitmap = true;
			assetData.inner = inner;
			return assetData;
		}
		
		public static function yellowBtnDown():AssetData
		{
			var inner : Rectangle = new Rectangle(8, 8, 64, 14);
			var assetData : AssetData = new AssetData("yellowBtnDown");
			assetData.isScaleBitmap = true;
			assetData.inner = inner;
			return assetData;
		}
		
		public static function yellowBtnUp():AssetData
		{
			var inner : Rectangle = new Rectangle(8, 8, 64, 14);
			var assetData : AssetData = new AssetData("yellowBtnUp");
			assetData.isScaleBitmap = true;
			assetData.inner = inner;
			return assetData;
		}
		
		public static function yellowBtnOver():AssetData
		{
			var inner : Rectangle = new Rectangle(8, 8, 64, 14);
			var assetData : AssetData = new AssetData("yellowBtnOver");
			assetData.isScaleBitmap = true;
			assetData.inner = inner;
			return assetData;
		}
		
		public static function newStateTipUp():AssetData
		{
			var inner:Rectangle = new Rectangle( 7, 7, 92, 12 );
			var assetData:AssetData = new AssetData( "BtnTipUp" );
			assetData.isScaleBitmap = true;
			assetData.inner = inner;
			return assetData;
		}
		
		public static function newStateTipDown():AssetData
		{
			var inner:Rectangle = new Rectangle( 7, 7, 92, 12 );
			var assetData:AssetData = new AssetData( "BtnTipDown" );
			assetData.isScaleBitmap = true;
			assetData.inner = inner;
			return assetData;
		}
		
		public static function newStateTipOver():AssetData
		{
			var inner:Rectangle = new Rectangle( 7, 7, 92, 12 );
			var assetData:AssetData = new AssetData( "BtnTipOver" );
			assetData.isScaleBitmap = true;
			assetData.inner = inner;
			return assetData;
		}
		
		public static function darkGreenBtnUp():AssetData
		{
			var inner:Rectangle = new Rectangle( 5, 5, 39, 14 );
			var assetData:AssetData = new AssetData( "DarkGreenBtnUp" );
			assetData.isScaleBitmap = true;
			assetData.inner = inner;
			return assetData;
		}
		
		public static function darkGreenBtnDown():AssetData
		{
			var inner:Rectangle = new Rectangle( 5, 5, 39, 14 );
			var assetData:AssetData = new AssetData( "DarkGreenBtnDown" );
			assetData.isScaleBitmap = true;
			assetData.inner = inner;
			return assetData;
		}
		
		public static function darkGreenBtnOver():AssetData
		{
			var inner:Rectangle = new Rectangle( 5, 5, 39, 14 );
			var assetData:AssetData = new AssetData( "DarkGreenBtnOver" );
			assetData.isScaleBitmap = true;
			assetData.inner = inner;
			return assetData;
		}
	}
}